﻿@model List<object>
@using HelpDeskTicketingApp.Adapters.DataAdapters
@{
    ViewBag.Title = "Stats";
}

<div class="row">
    <div class="col-lg-6">
        <div class="box box-danger">
            <div class="box-header">
                <h3 class="box-title">Issues in General</h3>
            </div>
            <div class="box-body chart-responsive">
                <div class="chart" id="issue-general-chart" style="height: 300px; position: relative;"></div>
            </div><!-- /.box-body -->
        </div><!-- /.box -->

    </div>

    <div class="col-lg-6">

        <!-- BAR CHART -->
        <div class="box box-success">
            <div class="box-header">
                <h3 class="box-title">Technichians in General</h3>
            </div>
            <div class="box-body chart-responsive">
                <div class="chart" id="tech-general-chart" style="height: 300px;"></div>
            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </div>

</div>

<div class="row">

    <div class="col-lg-10">

        <!-- BAR CHART -->
        <div class="box box-success">
            <div class="box-header">
                <h3 class="box-title">Issue Types in General</h3>
            </div>
            <div class="box-body chart-responsive">
                <div class="chart" id="IssueType-general-chart" style="height: 300px;"></div>
            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </div>


</div>







@section Scripts {
<script src="~/Scripts/raphael-min.js"></script>
<script src="~/Scripts/morris.min.js"></script>

    <script>
    $(document).ready(function () {

        //General Issue Donut Chart
        var donut = new Morris.Donut({
            element: 'issue-general-chart',
            resize: true,
            colors: ["#3c8dbc", "#f56954", "#00a65a"],
            data: [
                @{int count = 1;}
                @foreach (var item in Model[0] as Dictionary<string,int>)
	                    {
                            if (count < Model.Count)
                            {
                                 @Html.Raw("{label: \"" + item.Key + "\", value: " + item.Value + "},");
                            }
                            else
                            {
                                @Html.Raw("{label: \"" + item.Key + "\", value: " + item.Value + "}");
                            }
                            count++;

	                    }

            ],
            hideHover: 'auto'
        });

        //General Tech Bar Chart
        var bar = new Morris.Bar({
            element: 'tech-general-chart',
            resize: true,
            data: [

                 @{count = 1;}
                 @foreach (var item in Model[1] as List<GeneralTechStats>)
                            {
                               if (count < 3)
                              {
                                 @Html.Raw("{y: \""+ item.Name +"\" ,"+"a:"+item.a+", b:"+item.b+"},");
                              }
                                   
                               else
                                {
                                      @Html.Raw("{y: \""+ item.Name +"\" ,"+"a:"+item.a+", b:"+item.b+"}");
                                }

                                count++;
                            }

            ],
            barColors: ['#00a65a', '#f56954'],
            xkey: 'y',
            ykeys: ['a', 'b'],
            labels: ['Solved Issues', 'Working Now'],
            hideHover: 'auto'
        });


        //General Issue Types Bar Chart
        var bar = new Morris.Bar({
            element: 'IssueType-general-chart',
            resize: true,
            data: [

                 @{count = 1;
                   var IssueModel = Model[2] as List<GeneralIssueTypeStats>;
                   }
                 @foreach (var item in IssueModel)
                          {
                               if (count < IssueModel.Count)
                            {
                               @Html.Raw("{y: \""+ item.Name +"\" ,"+"a:"+item.a+"},");
                            }
                                   
                            else
                            {
                                 @Html.Raw("{y: \""+ item.Name +"\" ,"+"a:"+item.a+"}");
                            }

                            count++;
                 }

                    ],
                    barColors: ['#00a65a', '#f56954'],
                        xkey: 'y',
                    ykeys: ['a'],
                    labels: ['Total Issue'],
                    hideHover: 'auto'
                    });

    });
</script>>
}

